package com.lagou.stage1.module3.task2;

import java.util.LinkedList;
import java.util.List;

public class WorkerTest {
    public static void main(String[] args) {

        //(2)定义List集合，在List集合中增加三个员工，基本信息如下：  "凤姐" 18 20000  "欧阳峰" 60 8000  "刘德华" 40 30000
        Worker w1 = new Worker("凤姐",18,20000);
        Worker w2 = new Worker("欧阳峰",60,8000);
        Worker w3 = new Worker("刘德华",40,30000);
        List<Worker> l1 = new LinkedList<>();
        boolean b = l1.add(w1);
        System.out.println(w1 + "插入的结果是: " + b);
        b = l1.add(w2);
        System.out.println(w2 + "插入的结果是: " + b);
        b = l1.add(w3);
        System.out.println(w3 + "插入的结果是: " + b);
        //(3)在"欧阳峰"之前插入一个员工，信息为：姓名："张柏芝"，年龄：35，工资3300
        System.out.println("--------------------------------------------------------");
        Worker w4 = new Worker("张柏芝",35,3300);
        l1.add(1,w4);
        System.out.println(l1);

        //(4)删除"刘德华"的信息
        System.out.println("--------------------------------------------------------");
        l1.remove(3);
        //(5)利用for 循环遍历，打印List 中所有员工的信息
        System.out.println("--------------------------------------------------------");
        for (int i = 0; i < l1.size(); i++) {
            System.out.println("当前集合第" + i + "位的结果是: " + l1.get(i));
        }
        //(6)利用迭代遍历，对List 中所有的员工调用work 方法
        System.out.println("--------------------------------------------------------");
        for (Worker i: l1) {
            i.work();
        }
        //(7)为Worker类重写equals 方法，当姓名、年龄、工资全部相等时候才返回true
        //使用欧阳锋做测试
        //Worker w2 = new Worker("欧阳峰",60,8000);
        System.out.println("--------------------------------------------------------");
        b = w2.equals(new Worker("欧阳峰",60,8000));
        System.out.println("重写的equals方法判断结果是: " + b);
    }
}
